package com.atguigu.champter5.Flink05.transformation.partition;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class $1_ShuffleExample {
    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
//        env.setParallelism(2);
//        env.fromElements(1,2,3,4,5,6).print();
        //shuffle
/*        env
                .fromElements(1,2,3,4)
                .setParallelism(1)
                .shuffle().print().setParallelism(2);*/

        //rebalance
   /*     env
                .fromElements(1,2,3,4,5,6)
                .setParallelism(1)
                .map(Integer->Integer)
                .setParallelism(2)
                .rebalance().print().setParallelism(3);*/

        //rescale
        env
                .fromElements(1,2,3,4,5,6)
                .map(Integer->Integer)
                .setParallelism(2)
//                .rescale().print().setParallelism(4);
                .global().print();


        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
